package com.tinysand.advert;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * 广告检索微服务模块启动入口
 *
 * Created By TINY
 * Create Time 2020/2/26
 **/
@EnableFeignClients // 启用 Feign 支持，调用其他微服务
@EnableEurekaClient // 标识为一个 Eureka 客户端
@EnableHystrix      // 开启 Hystrix 支持
@EnableCircuitBreaker   // 启用断路器支持
@EnableDiscoveryClient  // 启用服务发现
@EnableHystrixDashboard // 启用 Hystrix 监控能力
@SpringBootApplication
public class SearchApplication {

    public static void main(String[] args) {
        SpringApplication.run(SearchApplication.class, args);
    }

    @Bean
    @LoadBalanced // 使用 Ribbon 的轮询实现负载均衡
    public RestTemplate restTemplate() { return new RestTemplate(); }
}
